package com.studyyoun.android.nonghe.msg.item;
/**
 * Created by zhaolong on 2017/10/7.
 * 站在顶峰，看世界
 * 落在谷底，思人生
 */

import android.animation.ObjectAnimator;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.ScaleAnimation;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.studyyoun.android.androidcommonbaselibrary.okhttp.callback.OkhttpCommonCallBack;
import com.studyyoun.android.androidcommonbaselibrary.okhttp.client.OkhttpCommonClient;
import com.studyyoun.android.androidcommonbaselibrary.utils.LogUtils;
import com.studyyoun.android.androidcommonbaselibrary.utils.ToastUtils;
import com.studyyoun.android.androidcommonbaselibrary.view.DropDownSpringbackScrollView;
import com.studyyoun.android.nonghe.R;
import com.studyyoun.android.nonghe.http.HttpUrlHelper;
import com.studyyoun.android.nonghe.msg.activity.MsgDetaileActivity;
import com.studyyoun.android.nonghe.msg.model.MsgModel;
import com.studyyoun.android.nonghe.share.QQShareFunction;
import com.studyyoun.android.nonghe.share.WeixinShareFunction;
import com.studyyoun.android.nonghe.share.WinxinSharModel;
import com.studyyoun.android.nonghe.welcom.CommonUserHelper;
import com.studyyoun.android.nonghe.welcom.model.UserModel;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/**
 * class infation
 */
public class ItemMsgDetaileOtherShareClass {
    private Context mContext;
    private Handler mHandler;
    private MsgModel mMsgModel;
    private PopupWindow mSharePopupWindow;
    private ImageView mAddMyCollectImageView;
    private String mImageUrl;
    private final ImageView mContentPariseImageView;
    private final TextView mContentPariseTextView;
    private final ImageView mBottomPariseImageView;
    private final LinearLayout mContentPariseLayout;
    private int mCurrentBottomType =-1;
    private ObjectAnimator mObjectAnimator;


    public ItemMsgDetaileOtherShareClass(MsgDetaileActivity context, Handler handler, final MsgModel msgModel) {

        mContext = context;
        mHandler = handler;
        mMsgModel = msgModel;

        /**
         * 图片链接
         */
        if (mMsgModel != null) {
            mImageUrl = mMsgModel.getImgUrl();
            String msgModelImgUrl = mMsgModel.getImgUrl();
            if (!TextUtils.isEmpty(msgModelImgUrl)) {
                if (msgModelImgUrl.contains(",")) {
                    String[] imageUrlSplit = msgModelImgUrl.split(",");
                    if (imageUrlSplit != null && imageUrlSplit.length > 0) {
                        mImageUrl = imageUrlSplit[0];
                    }
                }
            }
        }


        LinearLayout artShareBottomLinearLayout = context.findViewById(R.id.ll_art_bottom_share);
        artShareBottomLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LogUtils.d("show share ");
                showSharePopuwindow(view);
            }
        });
        /**
         * 点赞相关
         */
        mContentPariseLayout = context.findViewById(R.id.ll_msg_parise);
        mContentPariseImageView = context.findViewById(R.id.iv_msg_parise);
        mContentPariseTextView = context.findViewById(R.id.tv_msg_parise);
        mBottomPariseImageView = context.findViewById(R.id.iv_botton_msg_parise);
        if (mMsgModel != null) {
            UserModel userModel = CommonUserHelper.getUserModel();
            if (mMsgModel.pariseList != null && userModel != null && mMsgModel.pariseList.contains(String.valueOf(userModel.getUserId()))) {
                mContentPariseImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.art_parise2));
                mBottomPariseImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.art_parise2));
                mContentPariseTextView.setTextColor(Color.parseColor("#F5A623"));
                mContentPariseLayout.setBackground(mContext.getResources().getDrawable(R.drawable.bg_art_parise_shape));
            } else {
                mContentPariseImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.art_parise5));
                mBottomPariseImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.art_parise5));
                mContentPariseTextView.setTextColor(Color.parseColor("#969696"));
                mContentPariseLayout.setBackground(mContext.getResources().getDrawable(R.drawable.bg_art_no_parise_shape));
            }

            String pariseCount = "0";
            if (mMsgModel.pariseList != null) {
                pariseCount = String.valueOf(mMsgModel.pariseList.size());
            }
            mContentPariseTextView.setText(pariseCount + "赞");

        }

        mBottomPariseImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mMsgModel == null) {
                    ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                    return;
                }
                ScaleAnimation scaleAnimation = new ScaleAnimation(1.2f, 1f, 1.2f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                scaleAnimation.setDuration(200);
                scaleAnimation.setInterpolator(new LinearInterpolator());
                mBottomPariseImageView.startAnimation(scaleAnimation);
                UserModel userModel = CommonUserHelper.getUserModel();
                if (userModel != null) {
                    if (msgModel.pariseList != null && msgModel.pariseList.contains(String.valueOf(userModel.getUserId()))) {
                        ToastUtils.show("您已点过赞了", mContext);
                    } else {
                        //点赞
                        addMsgPariseFunction();
                    }
                } else {
                    //请登录
                    ToastUtils.show("请登录", mContext);
                }
            }
        });
        mContentPariseLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mMsgModel == null) {
                    ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                    return;
                }
                UserModel userModel = CommonUserHelper.getUserModel();

                ScaleAnimation scaleAnimation = new ScaleAnimation(1.2f, 1f, 1.2f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                scaleAnimation.setDuration(200);
                scaleAnimation.setInterpolator(new LinearInterpolator());
                mContentPariseImageView.startAnimation(scaleAnimation);

                if (userModel != null) {
                    if (msgModel.pariseList != null && msgModel.pariseList.contains(String.valueOf(userModel.getUserId()))) {
                        ToastUtils.show("您已点过赞了", mContext);
                    } else {
                        //点赞
                        addMsgPariseFunction();
                    }
                } else {
                    //请登录
                    ToastUtils.show("请登录", mContext);
                }
            }
        });

        /**
         * 收藏相关
         */
        LinearLayout addMyCollectLinearLayout = context.findViewById(R.id.ll_botton_art_my_colect);
        mAddMyCollectImageView = context.findViewById(R.id.iv_botton_art_my_colect);
        if (mMsgModel != null && CommonUserHelper.getUserModel() != null) {
            if (mMsgModel.collectList != null && mMsgModel.collectList.contains(String.valueOf(CommonUserHelper.getUserModel().getUserId()))) {
                mAddMyCollectImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.my_cllect_icon4));
            } else {
                mAddMyCollectImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.my_cllect_icon3));
            }
        }
        addMyCollectLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mMsgModel == null) {
                    ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                    return;
                }
                UserModel userModel = CommonUserHelper.getUserModel();
                if (userModel != null) {
                    if (mMsgModel.collectList != null && mMsgModel.collectList.contains(String.valueOf(userModel.getUserId()))) {
                        ToastUtils.show("已收藏", mContext);
                    } else {
                        mHandler.postDelayed(new Runnable() {
                            @Override
                            public void run() {

                                ScaleAnimation scaleAnimation = new ScaleAnimation(1.2f, 1f, 1.2f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                                scaleAnimation.setDuration(200);
                                scaleAnimation.setInterpolator(new LinearInterpolator());
                                mAddMyCollectImageView.startAnimation(scaleAnimation);
                                addMsgModelToMyColocet();
                            }
                        }, mDelayTime);
                    }
                } else {
                    ToastUtils.show("请登录", mContext);
                    CommonUserHelper.toLoginPage();
                }


            }
        });

        final DropDownSpringbackScrollView springbackScrollView = context.findViewById(R.id.ddsv_main_msg_content);
        final WebView msgContentWebView = context.findViewById(R.id.tv_msg_content);
        FrameLayout recommentFrameLayout = context.findViewById(R.id.fl_recomment);
        recommentFrameLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mCurrentScrollLocation==1) {
                    mCurrentScrollLocation=2;
                    springbackScrollView.smoothScrollTo(0,msgContentWebView.getTop()+msgContentWebView.getHeight());
                }else {
                    mCurrentScrollLocation=1;
                    springbackScrollView.smoothScrollTo(0,0);
                }
            }
        });
        final LinearLayout artBottomLayout = context.findViewById(R.id.ll_art_bottom_layout);
        springbackScrollView.setOnCustomScrollChangeLisernet(new DropDownSpringbackScrollView.OnCustomScrollChangeLisernet() {
            @Override
            public void onScrollChanged(int l, int t, int oldl, int oldt) {
                LogUtils.d("l "+l+"  "+t+" -- ol "+oldl+"  "+oldt);
                int flagTop = t-oldt;
                if (flagTop>0){
                    if (mCurrentBottomType!=1) {
                        mCurrentBottomType=1;
                        if (mObjectAnimator != null) {
                            if (mObjectAnimator.isRunning()) {
                                mObjectAnimator.cancel();
                            }
                        }
                        mObjectAnimator = ObjectAnimator.ofFloat(artBottomLayout,"translationY",artBottomLayout.getHeight());
                        mObjectAnimator.setDuration(200);

                        mObjectAnimator.setInterpolator(new LinearInterpolator());
                        mObjectAnimator.start();
                    }

                }else {
                    if (mCurrentBottomType==1) {
                        mCurrentBottomType=-1;

                        if (mObjectAnimator != null) {
                            if (mObjectAnimator.isRunning()) {
                                mObjectAnimator.cancel();
                            }
                        }
                        //向上
                        mObjectAnimator = ObjectAnimator.ofFloat(artBottomLayout, "translationY", 0);
                        mObjectAnimator.setDuration(200);
                        mObjectAnimator.setInterpolator(new LinearInterpolator());
                        mObjectAnimator.start();
                    }
                }
            }
        });
    }

    private int mCurrentScrollLocation = 1;

    //-----分享————————————

    private void showSharePopuwindow(View view) {
        if (mSharePopupWindow != null) {
            mSharePopupWindow.dismiss();
            mSharePopupWindow = null;
            return;
        }
        // 获取自定义布局文件activity_popupwindow_left.xml的视图
        View popupWindow_view = View.inflate(view.getContext(), R.layout.pop_share_layout, null);

        // 创建PopupWindow实例,200,LayoutParams.MATCH_PARENT分别是宽度和高度
        mSharePopupWindow = new PopupWindow(popupWindow_view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
        //焦点设置
        mSharePopupWindow.setFocusable(true);
        //设置点击背景不消失
        mSharePopupWindow.setOutsideTouchable(true);
        // 设置透明背景
        mSharePopupWindow.setBackgroundDrawable(new ColorDrawable(
                Color.TRANSPARENT));
        //设置动画

        mSharePopupWindow.setAnimationStyle(com.studyyoun.android.androidcommonbaselibrary.R.style.popwin_from_bottom_anim_style);

        mSharePopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {

            }
        });
        //显示
        mSharePopupWindow.showAtLocation(view, Gravity.NO_GRAVITY, 0, 0);


        TextView cancleShareTextView = popupWindow_view.findViewById(R.id.tv_cancle_share);
        cancleShareTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mSharePopupWindow.dismiss();
                mSharePopupWindow = null;
            }
        });

        LinearLayout shareWeiXinMsgLayout = popupWindow_view.findViewById(R.id.ll_share_weixin_msg_bot);
        shareWeiXinMsgLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LogUtils.d("wei xin msg share ");
                closeSharePop();
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mMsgModel == null) {
                            ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                            return;
                        }
                        String artName = "《智慧安卓》【精彩时刻】 " + mMsgModel.getMsgTitle();
                        String artFalg = mMsgModel.getMsgRemark();


                        String htmlUrl = HttpUrlHelper.sMsgShareUrl + "?id=" + mMsgModel.getId();

                        WinxinSharModel winxinSharModel = new WinxinSharModel();

                        winxinSharModel.webUrl = htmlUrl;
                        winxinSharModel.description = artFalg;
                        winxinSharModel.title = artName;

                        WeixinShareFunction.getInstance().shareWebFunction(winxinSharModel, WeixinShareFunction.ShareType.MSG);
                    }
                }, mDelayTime);


            }
        });

        LinearLayout shareWeiXinRingLayout = popupWindow_view.findViewById(R.id.ll_share_weixin_ring_bot);
        shareWeiXinRingLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LogUtils.d("wei xin ring share ");
                closeSharePop();
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mMsgModel == null) {
                            ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                            return;
                        }
                        String artName = "《智慧安卓》【精彩时刻】 " + mMsgModel.getMsgTitle();
                        String artFalg = mMsgModel.getMsgRemark();

                        String htmlUrl = HttpUrlHelper.sMsgShareUrl + "?id=" + mMsgModel.getId();

                        WinxinSharModel winxinSharModel = new WinxinSharModel();

                        winxinSharModel.webUrl = htmlUrl;
                        winxinSharModel.description = artFalg;
                        winxinSharModel.title = artName;

                        WeixinShareFunction.getInstance().shareWebFunction(winxinSharModel, WeixinShareFunction.ShareType.FIND);
                    }
                }, mDelayTime);


            }
        });

        LinearLayout shareQqMsgLayout = popupWindow_view.findViewById(R.id.ll_share_bottom_qq_msg);
        shareQqMsgLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LogUtils.d("qq msg share ");
                closeSharePop();
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mMsgModel == null) {
                            ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                            return;
                        }
                        QQShareFunction.getInstance().shareMsgAndMsgToQQ((MsgDetaileActivity) mContext, mMsgModel);
                    }
                }, mDelayTime);

            }
        });
        LinearLayout shareQqRingLayout = popupWindow_view.findViewById(R.id.ll_share_qq_ring_bot);
        shareQqRingLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LogUtils.d("qq ring share ");
                closeSharePop();
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mMsgModel == null) {
                            ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                            return;
                        }
                        QQShareFunction.getInstance().shareMsgAndMsgToQQQzone((MsgDetaileActivity) mContext, mMsgModel);
                    }
                }, mDelayTime);


            }
        });

        LinearLayout shareWeiXinCollectLayout = popupWindow_view.findViewById(R.id.ll_share_weixin_collect);
        shareWeiXinCollectLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LogUtils.d("wei xin collect share ");

                closeSharePop();
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mMsgModel == null) {
                            ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                            return;
                        }
                        String artName = "《智慧安卓》 【精彩时刻】" + mMsgModel.getMsgTitle();
                        String artFalg = mMsgModel.getMsgRemark();


                        String htmlUrl = HttpUrlHelper.sMsgShareUrl + "?id=" + mMsgModel.getId();

                        WinxinSharModel winxinSharModel = new WinxinSharModel();

                        winxinSharModel.webUrl = htmlUrl;
                        winxinSharModel.description = artFalg;
                        winxinSharModel.title = artName;

                        WeixinShareFunction.getInstance().shareWebFunction(winxinSharModel, WeixinShareFunction.ShareType.COLLE);
                    }
                }, mDelayTime);


            }
        });

        LinearLayout copyLoationLinearLayout = popupWindow_view.findViewById(R.id.ll_copy_location);
        copyLoationLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (mMsgModel == null) {
                    ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                    return;
                }
                String artName = "《智慧安卓》【精彩时刻】 " + mMsgModel.getMsgTitle() + "  点击链接查看详情  " + HttpUrlHelper.sMsgShareUrl + "?id=" + mMsgModel.getId();

                // 从API11开始android推荐使用android.content.ClipboardManager
                // 为了兼容低版本我们这里使用旧版的android.text.ClipboardManager，虽然提示deprecated，但不影响使用。
                ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);

                // 将文本内容放到系统剪贴板里。
                cm.setText(artName);
                closeSharePop();
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ToastUtils.show("已复制时刻信息到剪切版", mContext);
                    }
                }, mDelayTime);

            }
        });

        //添加到我的收藏

        LinearLayout addMyCollectLinearLayout = popupWindow_view.findViewById(R.id.ll_my_collect);
        addMyCollectLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (mMsgModel == null) {
                    ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                    return;
                }

                closeSharePop();

                UserModel userModel = CommonUserHelper.getUserModel();
                if (userModel != null) {
                    if (mMsgModel.collectList != null && mMsgModel.collectList.contains(String.valueOf(userModel.getUserId()))) {
                        ToastUtils.show("已收藏", mContext);
                    } else {
                        mHandler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                addMsgModelToMyColocet();
                            }
                        }, mDelayTime);
                    }
                } else {
                    ToastUtils.show("请登录", mContext);
                    CommonUserHelper.toLoginPage();
                }

            }
        });

        LinearLayout otherShareLayout = popupWindow_view.findViewById(R.id.ll_share_other);
        otherShareLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                closeSharePop();
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mMsgModel == null) {
                            ToastUtils.show("暂无时刻详情，请重新进入 ", mContext);
                            return;
                        }
                        String artName = "《智慧安卓》【精彩时刻】 " + mMsgModel.getMsgTitle() + "  点击链接查看详情  " + HttpUrlHelper.sMsgShareUrl + "?id=" + mMsgModel.getId();

                        Intent shareIntent = new Intent();
                        shareIntent.setAction(Intent.ACTION_SEND);
                        shareIntent.putExtra(Intent.EXTRA_TEXT, artName);
                        shareIntent.setType("text/plain");
                        shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        mContext.startActivity(shareIntent);
                    }
                }, mDelayTime);
            }
        });


        LinearLayout otherBackgroundLayout = popupWindow_view.findViewById(R.id.ll_share_background_other);
        otherBackgroundLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                closeSharePop();
            }
        });

    }

    /**
     * 添加时刻至我的收藏
     */
    private void addMsgModelToMyColocet() {

        UserModel userModel = CommonUserHelper.getUserModel();
        if (userModel != null) {
            commitaddMsgModelToMyColocet();
        } else {
            ToastUtils.show("请登录", mContext);
        }


    }

    /**
     * 提交数据
     */
    private void commitaddMsgModelToMyColocet() {

        if (mMsgModel.collectList != null && mMsgModel.collectList.contains(CommonUserHelper.getUserModel().getUserId())) {
            //取消收藏
            String url = HttpUrlHelper.msgCanleCollectUrl;
            ConcurrentHashMap<String, String> key = new ConcurrentHashMap<>();
            key.put("msgId", String.valueOf(mMsgModel.getId()));
            key.put("userId", CommonUserHelper.getUserModel().getUserId() + "");

            OkhttpCommonClient.sentPostRequest(url, key, new OkhttpCommonCallBack() {
                @Override
                public void onSuccess(Object obj) {
                    ToastUtils.show("取消收藏成功 ", mContext);
                    List<String> articlPariseModels = mMsgModel.collectList;
                    if (articlPariseModels != null) {
                        articlPariseModels.remove(CommonUserHelper.getUserModel().getUserId() + "");
                    }
                    mMsgModel.collectList = articlPariseModels;
                    //ArtSqlDBHelper mArtSqlDBHelper = new ArtSqlDBHelper(mContext);
                    //mArtSqlDBHelper.insertArt(mMsgModel);

                    mAddMyCollectImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.my_cllect_icon3));
                }

                @Override
                public void onFaile(Object obj) {
                    ToastUtils.show("收藏失败", mContext);
                }
            });
        } else {

            String url = HttpUrlHelper.msgAddCollectUrl;
            ConcurrentHashMap<String, String> key = new ConcurrentHashMap<>();
            key.put("msgId", String.valueOf(mMsgModel.getId()));
            key.put("userId", CommonUserHelper.getUserModel().getUserId() + "");

            OkhttpCommonClient.sentPostRequest(url, key, new OkhttpCommonCallBack() {
                @Override
                public void onSuccess(Object obj) {
                    ToastUtils.show("收藏成功 ", mContext);
                    List<String> articlPariseModels = mMsgModel.collectList;
                    if (articlPariseModels != null) {
                        articlPariseModels.add(CommonUserHelper.getUserModel().getUserId() + "");
                    } else {
                        List<String> list = new ArrayList<String>();
                        list.add(CommonUserHelper.getUserModel().getUserId() + "");
                        mMsgModel.collectList = list;
                    }
                    //ArtSqlDBHelper mArtSqlDBHelper = new ArtSqlDBHelper(mContext);
                    //mArtSqlDBHelper.insertArt(mMsgModel);

                    mAddMyCollectImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.my_cllect_icon4));
                }

                @Override
                public void onFaile(Object obj) {
                    ToastUtils.show("收藏失败", mContext);
                }
            });
        }
    }


    private void addMsgPariseFunction() {
        String url = HttpUrlHelper.msgPairseUrl;
        ConcurrentHashMap<String, String> key = new ConcurrentHashMap<>();
        key.put("msgId", String.valueOf(mMsgModel.getId()));
        key.put("userId", CommonUserHelper.getUserModel().getUserId() + "");

        OkhttpCommonClient.sentPostRequest(url, key, new OkhttpCommonCallBack() {
            @Override
            public void onSuccess(Object obj) {
                ToastUtils.show("点赞成功 ", mContext);
                List<String> articlPariseModels = mMsgModel.pariseList;
                if (articlPariseModels != null) {
                    articlPariseModels.add(CommonUserHelper.getUserModel().getUserId() + "");
                }
                mMsgModel.pariseList = articlPariseModels;
                //ArtSqlDBHelper mArtSqlDBHelper = new ArtSqlDBHelper(mContext);
                //mArtSqlDBHelper.insertArt(mMsgModel);

                mContentPariseImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.art_parise2));
                mBottomPariseImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.art_parise2));
                mContentPariseTextView.setTextColor(Color.parseColor("#F5A623"));
                mContentPariseTextView.setText(mMsgModel.pariseList.size() + "赞");
                mContentPariseLayout.setBackground(mContext.getResources().getDrawable(R.drawable.bg_art_parise_shape));
            }

            @Override
            public void onFaile(Object obj) {
                ToastUtils.show("点赞失败", mContext);
            }
        });
    }


    private long mDelayTime = 300;

    private void closeSharePop() {
        if (mSharePopupWindow != null) {
            mSharePopupWindow.dismiss();
            mSharePopupWindow = null;
        }
    }


}
